﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using MoaDashboard.Includes;
using System.Web.Routing;


namespace MoaDashboard.Includes
{
    public class MenuManager
    {
        public static string Generate(params MenuItem[] list)
        {
            if (list == null)
            {
                return "";
            }

            var builder = new StringBuilder();
            foreach (MenuItem item in list)
            {
                var httpContext = new HttpContextWrapper(HttpContext.Current);

                UrlHelper urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current))));

                builder.AppendFormat("<li class=\"menu-news\"><a href=\"{0}\"><i></i>{1}</a></li>", urlHelper.Action(item.Action, item.Controller, item.Param), item.Title);
            }

            return builder.ToString();
        }
    }

}